<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

if (($city = $route->GET('city')) != "")
{
	$areas = $db->getTable("select `area_id`,`name` from `areas` where `city_id` = '$city' order by `name`");
	if (count($areas) > 0)
	{
		$json = "[";
		for ($i=0; $i < count($areas); $i++)
		{
			$json .= "{\"area_id\":\"".$areas[$i]['area_id']."\",\"name\":\"".$areas[$i]['name']."\"}";
			if ($i < count($areas) - 1)
				$json .= ",";
		}
		$json .= "]";
		echo $json;
	}
}

?>